package com.cyt.sys.extend.netty;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

import javax.servlet.ServletContext;

/**
 * 初始化时启动
 *
 * @author taocongcong
 * @create 2019-03-12 16:29
 */
@Component
public class WebSocketInit implements InitializingBean, ServletContextAware {

    @Override
    public void afterPropertiesSet() throws Exception {

    }

    @Override
    public void setServletContext(ServletContext servletContext) {
        new WebSocketThread().start();
    }

    /**
     * 开启netty服务
     * @author congcong tao
     * @date 2019/4/1 8:50
     */
    private class WebSocketThread extends Thread {
        @Override
        public void run() {
            try {
                //new WebSocketServer(9898).start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
